//
//  SNShopHotProductModel.m
//  app
//
//  Created by 王少宁 on 15/8/20.
//  Copyright (c) 2015年 hdaren. All rights reserved.
//

#import "SNShopHotProductModel.h"

@implementation SNShopHotProductModel

- (instancetype)initWithArray:(NSArray *)array
{
    if ([super initWithArray:array]) {
        
        if (array && array.count) {
            NSMutableArray * mutableArray = [NSMutableArray array];
            for (NSDictionary * dic in array) {
                SNShopHotProductSubModel * model = [SNShopHotProductSubModel modelWithDict:dic];
                [mutableArray addObject:model];
            }
            _hotProductArray = mutableArray;
            
            self.rowNumber = (int)array.count;
            self.cellHeight = SCREEN_WIDTH * 190/720;
            self.headerView = YES;
            self.headerTitle = @"小区爆品";
        }
    }
    return self;
}

@end






@implementation SNShopPromotionModel

- (instancetype)initWithDict:(NSDictionary *)dict
{
    if ([super init]) {
        _name = dict[@"name"];
    }
    return self;
}

+ (instancetype)modelWithDict:(NSDictionary *)dict
{
    return [[self alloc] initWithDict:dict];
}

@end







@implementation SNShopHotProductSubModel

- (instancetype)initWithDict:(NSDictionary *)dict
{
    if ([super init]) {
        _shop_id = [dict[@"shop_id"] stringValue];
        _brand_id = [dict[@"brand_id"] stringValue];
        _classify_id = [dict[@"classify_id"] stringValue];
        _product_id = [dict[@"product_id"] stringValue];
        _product_title = dict[@"product_title"];
        _pic = dict[@"pic"];
        _width = [dict[@"width"] stringValue];
        _height = [dict[@"height"] stringValue];
        CGFloat tag_price = [dict[@"tag_price"] floatValue];
        _tag_price = [NSString stringWithFormat:@"%.2f",tag_price];
        CGFloat sale_price = [dict[@"sale_price"] floatValue];
        _sale_price = [NSString stringWithFormat:@"%.2f",sale_price];
        _num = [dict[@"num"] stringValue];
        _sale_num = [dict[@"sale_num"] stringValue];
        _ptype = [dict[@"ptype"] stringValue];
        _jifen = [dict[@"jifen"] stringValue];
        _isHot = [dict[@"isHot"] stringValue];
        _open_time = dict[@"open_time"];
        _shop_name = dict[@"shop_name"];
        _brand_name = dict[@"brand_name"];
        
        NSArray * promotionArray = dict[@"promotion"];
        NSMutableArray * mutableArray = [NSMutableArray array];
        if (promotionArray && promotionArray.count) {
            for (NSDictionary * dic in promotionArray) {
                SNShopPromotionModel * model = [SNShopPromotionModel modelWithDict:dic];
                [mutableArray addObject:model];
            }
        }
        _promotionArray = mutableArray;
        
    }
    return self;
}

+ (instancetype)modelWithDict:(NSDictionary *)dict
{
    return [[self alloc] initWithDict:dict];
}

@end